
ROBOT_SPORT_AI_ID_DAMP = 1001
ROBOT_SPORT_API_ID_BALANCESTAND = 1002
ROBOT_SPORT_API_ID_STOPMOVE = 1003
ROBOT_SPORT_API_ID_STANDUP = 1004
ROBOT_SPORT_API_ID_STANDDOWN = 1005
ROBOT_SPORT_API_ID_RECOVERYSTAND = 1006
ROBOT_SPORT_API_ID_EULER = 1007
ROBOT_SPORT_API_ID_MOVE = 1008
ROBOT_SPORT_API_ID_SIT = 1009
ROBOT_SPORT_API_ID_RISESIT = 1010
ROBOT_SPORT_API_ID_SWITCHGAIT        = 1011
ROBOT_SPORT_API_ID_BODYHEIGHT        = 1013;
ROBOT_SPORT_API_ID_SPEEDLEVEL = 1015
ROBOT_SPORT_API_ID_HELLO = 1016
ROBOT_SPORT_API_ID_STRETCH = 1017
ROBOT_SPORT_API_ID_CONTENT = 1020
ROBOT_SPORT_API_ID_DANCE1 = 1022
ROBOT_SPORT_API_ID_DANCE2 = 1023
ROBOT_SPORT_API_ID_SWITCHJOYSTICK = 1027
ROBOT_SPORT_API_ID_POSE = 1028
ROBOT_SPORT_API_ID_SCRAPE = 1029
ROBOT_SPORT_API_ID_FRONTFLIP = 1030
ROBOT_SPORT_API_ID_FRONTJUMP = 1031
ROBOT_SPORT_API_ID_FRONTPOUNCE = 1032
ROBOT_SPORT_API_ID_HEART = 1036
ROBOT_SPORT_API_ID_STATICWALK = 1061
ROBOT_SPORT_API_ID_TROTRUN = 1062
ROBOT_SPORT_API_ID_ECONOMICGAIT = 1063
ROBOT_SPORT_API_ID_LEFTFLIP = 2041
ROBOT_SPORT_API_ID_BACKFLIP = 2043
ROBOT_SPORT_API_ID_HANDSTAND = 2044
ROBOT_SPORT_API_ID_FREEWALK = 2045
ROBOT_SPORT_API_ID_FREEBOUND = 2046
ROBOT_SPORT_API_ID_FREEJUMP = 2047
ROBOT_SPORT_API_ID_FREEAVOID = 2048
ROBOT_SPORT_API_ID_CLASSICWALK = 2049
ROBOT_SPORT_API_ID_WALKUPRIGHT = 2050
ROBOT_SPORT_API_ID_CROSSSTEP = 2051
ROBOT_SPORT_API_ID_AUTORECOVERY_SET = 2054
ROBOT_SPORT_API_ID_AUTORECOVERY_GET = 2055
ROBOT_SPORT_API_ID_SWITCHAVOIDMODE = 2058


class UnitreeRequest:
    def __init__(self) -> None:
        self.request_identity:dict = {}
        self.request_lease:dict = {}
        self.request_policy:dict = {}
        self.request_header:dict = {}
        self.request:dict = {}

    def setRequestIdentity(self,id:int=None,api_id:int=None):
        self.request_identity = {'id': 0, 'api_id': 0}
        if id is not None:
            self.request_identity['id'] = id
        if api_id is not None:
            self.request_identity['api_id'] = api_id

    def setRequestLease(self,id:int=None):
        self.request_lease = {'id': 0}
        if id is not None:
            self.request_lease['id'] = id


    def setRequestPolicy(self,priority:int=None,noreply:bool=None):
        self.request_policy = {'priority': 0, 'noreply': False}
        if priority is not None:
            self.request_policy['priority'] = priority
        if noreply is not None:
            self.request_policy['noreply'] = noreply


    def setRequestHeader(self):
        self.request_header = {
            'identity': self.request_identity,
            'lease': self.request_lease,
            'policy': self.request_policy,
        }

    def Request(self,parameter:str=None,binary:list=[], if_header_set:bool=False) -> dict:
        if not if_header_set:
            self.setRequestIdentity()
            self.setRequestLease()
            self.setRequestPolicy()

        self.setRequestHeader()
        
        self.request = {
            'header': self.request_header,
            'parameter': "",
            'binary': [],
        }
       
        if parameter is not None:
            self.request['parameter'] = parameter
            
        if binary  is not None:
            self.request['binary'] = binary
            
        
        return self.request

